package zyc.java.project.springbootprojectweb.controller;

import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zyc.java.project.springbootprojectweb.pojo.User;
import java.util.List;

import zyc.java.project.springbootprojectweb.service.UserService;
import zyc.java.project.springbootprojectweb.service.impl.UserServiceImpl;

@RestController
public class UserController {

    private final UserService userService;

    @RequestMapping("/users")
    public String user() {
        List<User> users = userService.findAll();
        return JSONUtil.toJsonStr(users, JSONConfig.create().setDateFormat("yyyy-MM-dd HH:mm:ss"));
    }

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }
}
